/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef _DrivePath_hpp_
#define _DrivePath_hpp_

#include <list>
#include "picking/picking.hpp"
#include "GLDisplay.hpp"
#include "CoordinateDriveClient.hpp"
#include "sync.hpp"


namespace MuRo
{

class CCoordinateDriveDevice;
  
class CDrivePath : public CGLPickable, public CGLPickCallback, private gim::CSync
{
  public:
    //CDrivePath(CMachine *machine);
    CDrivePath(CCoordinateDriveDevice *device);
    
    ~CDrivePath();
    
    void Draw(const TViewParams &view);
    
    void AddPoint(float x, float y);
    
    void RemoveSelectedPoints();
    
    void Clear();
    
    void SetPickingContext(CGLPickingContext *context);
    
    void DrawPickable();
    
    void OnPick(TGLPickEvent event);
    
    void OnDrag(TGLPickEvent event);
    
    void SendPoints(MaCI::CoordinateDrive::CCoordinateDriveClient *coordinateDriveClient);
    
    bool selected;
    bool editable;
  private:
    
    class CDrivePoint : public CGLPickable, public CGLPickCallback
    {
      public:
    
        CDrivePoint(CDrivePath *path);
    
        void Draw(const TViewParams &view);
    
        void DrawPickable();
    
        void OnPick(TGLPickEvent event);
    
        void OnDrag(TGLPickEvent event);
        
        float x, y;
        CDrivePath *path;
        TViewParams view;
        bool selected;
    };
    
    float px, py;
    
    std::list<CDrivePoint*> points;
    CDrivePoint* selectedPoint;
    CGLPickingContext *pickingContext;
    CCoordinateDriveDevice *device;
    //CMachine *machine;
};

}
#endif
